

#ifndef __BINARY_TREE_H__
#define __BINARY_TREE_H__

/*节点*/
typedef struct BsTreeNode
{
    int         data;/*数据*/
    struct  BsTreeNode *left;/*左子树*/
    struct  BsTreeNode *right;/*右子树*/

}BSTREE_NODE;

/*二叉树*/
typedef struct BsTree
{
    BSTREE_NODE *root;/*树根*/
    int         size;
}BSTREE;

/*建树*/
BSTREE *bstree_create(void);

/*销毁树*/
void bstree_destroy(BSTREE *bstree);

/*插入节点*/
void bstree_insert(BSTREE *bstree, int data);

/*删除节点*/
int bstree_erase(BSTREE *bstree, int data);

/*删除所有匹配数据*/
void bstree_remove(BSTREE *bstree, int data);

/*清空*/
void bstree_clear(BSTREE *bstree);

/*更新节点,并保持有序树的特性*/
void bstree_update(BSTREE *bstree, int old, int new);


/*判断树是否存在*/
int bstree_exist(BSTREE *bstree, int data);

/*先序遍历*/
void bstree_pretravel(BSTREE *bstree);

/*中序遍历*/
void bstree_intravel(BSTREE *bstree);

/*后序遍历*/
void bstree_postravel(BSTREE *bstree);

/*大小*/
int bstree_size(BSTREE *bstree);

/*高度*/
int bstree_height(BSTREE *bstree);


/*打印*/
void bstree_print(BSTREE *bstree);

#endif
